Learning Flex Basics (Part 2): Creating a Simple Calculator with Macromedia Flex
Table of Contents
- Introduction
- Building the Calculator
- Create the Application Object
- Add a Panel for the Calculator
- Add the Calculator Display
- Add a Grid to Lay Out the Buttons
- Add the Calculator Buttons
- Create the CalculatorController Class
- Add Properties to the Controller Class
- Add Controller Methods
- Instantiate the CalculatorController Class
- Complete Code Listing for calculator.mxml
- Complete Code Listing for CalculatorController.as
- Where to Go From Here
Create the Application Object
To begin any Flex application, start with an XML declaration and an Application tag
block. The Application tag include a namespace declaration for the MX
class library: xmlns:mx="http://www.macromedia.com/2003/mxml". The mx prefix
is used with all tags for this library.
- Create a new file and save it as calculator.mxml in the flex_tutorials directory.
- At the beginning of the file, insert the XML declaration:
<?xml version="1.0">
-
After the XML declaration, add an
Applicationtag with the MXML namespace:<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> </mx:Application>